#include "digr.h"
#include <iostream>

int main() {

  deque<DiGrNode*> *queue1 = new deque<DiGrNode*>();
  deque<DiGrNode*> *queue2 = new deque<DiGrNode*>();
  
  DiGrNode *p = new DiGrNode();
  DiGrNode *c1 = new DiGrNode();
  DiGrNode *c2 = new DiGrNode();
  DiGrNode *c3 = new DiGrNode();
  DiGrNode *c4 = new DiGrNode();

  new DiGrEdge(p,c1);
  new DiGrEdge(p,c2);
  new DiGrEdge(p,c3);
  new DiGrEdge(p,c4);

  c1->setAttribute("foo",7);
  c2->setAttribute("foo",10);
  c3->setAttribute("foo",1);
  c4->setAttribute("foo",8);

  std::cout << "c1: " << c1->getAttribute("foo") << " " << c1 << std::endl;
  std::cout << "c2: " << c2->getAttribute("foo") << " " << c2 << std::endl;
  std::cout << "c3: " << c3->getAttribute("foo") << " " << c3 << std::endl;
  std::cout << "c4: " << c4->getAttribute("foo") << " " << c4 << std::endl;

  std::cout << "first 3 ascending:" << std::endl;

  DiGrAddBy(p, queue1, FRONT, ADDBY_NODE, "foo", ASCENDING, 3);

  for (int n = 0; n < queue1->size(); n++) {
    std::cout << (queue1->at(n))->getAttribute("foo") << std::endl;
  }

  std::cout << "first 2 descending:" << std::endl;

  DiGrAddBy(p, queue2, FRONT, ADDBY_NODE, "foo", DESCENDING, 2);

  for (int n = 0; n < queue2->size(); n++) {
    std::cout << (queue2->at(n))->getAttribute("foo") << std::endl;
  }

  return 0;
}
